﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using LibNiconico.NiconicoApi.Internal;
using System.Xml;
using System.Xml.Linq;
using LibNiconico.NiconicoApi.Extentions;

namespace LibNiconico.NiconicoApi.Lives.Comments
{
    /// <summary>
    /// ニコニコ生放送チャットコメント
    /// </summary>
    public sealed class NicoLiveChatComment:NicoXmlSocketChatComment
    {
        private NicoLiveChatComment() { }

        /// <summary>
        /// name属性
        /// </summary>
        public string Name { get; private set; }

        /// <summary>
        /// 接続した者のコメントであるか判定
        /// </summary>
        public bool YourPost { get; private set; }

        /// <summary>
        /// メッセージを解析し、コメントを生成
        /// </summary>
        /// <param name="message"></param>
        /// <returns></returns>
        public static NicoLiveChatComment Parse(XElement message)
        {
            NicoLiveChatComment comment = new NicoLiveChatComment();
            NicoXmlSocketChatComment.Parse(comment, message);



            comment.YourPost = XElementExtention.GetAttributeAsBool(message, "yourpost");
            comment.Name = XElementExtention.GetAttributeAsString(message, "name");
            return comment;
        }
    }
}
